//
//  ViewController.m
//  图文混排
//
//  Created by YYY on 2017/8/28.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    /*
    frame和bounds的区别
    frame：x,y决定当前控件相当于父视图的位置
    bounds：x,y决定当前控件相当于原点的位置
     */
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 200, 30)];
    label.font = [UIFont systemFontOfSize:14];
    [self.view addSubview:label];
    
    //附件
    NSTextAttachment *attachment = [[NSTextAttachment alloc]init];
    attachment.bounds = CGRectMake(0, -4, label.font.lineHeight+5, label.font.lineHeight+5);
    attachment.image = [UIImage imageNamed:@"表情"];
    
    //设置图片属性
    NSAttributedString *imageStr = [NSAttributedString attributedStringWithAttachment:attachment];
    label.attributedText = imageStr;
    
    //设置可变文本属性
    NSMutableAttributedString *mutableString = [[NSMutableAttributedString alloc]initWithString:@"我"];
    
    //拼接图片、文本
    [mutableString appendAttributedString:imageStr];
    
    NSAttributedString *str = [[NSAttributedString alloc]initWithString:@"时间流逝"];
    [mutableString appendAttributedString:str];
    
    //设置文本属性
    label.attributedText = mutableString;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
